<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let url = 'https://www.qq.com/query?id=news&name=search&ref=website'
      let arr = new URL(url).search.slice(1).split("&") 
      //["id=news", "name=search", "ref=website"]
      let obj ={}
      arr.forEach(item=>{
        let newArr = item.split('=')
        obj[newArr[0]]= newArr[1]
      })

      console.log(obj)
    </script>
  </body>
</html>
